<?xml version="1.0" encoding="UTF-8"?>
<?xmlspysamplexml C:\temp\tor-data\test.xml?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
	<xsl:template match="pdml">
		<data>
		<xsl:for-each select="./packet">
		<packet>
			<timestamp><xsl:value-of select="./proto[@name='geninfo']/field[@name='timestamp']/@show"></xsl:value-of></timestamp>
			<xsl:for-each select="./proto[@name='ip']/field[@name='ip.dst']">
				<target>
					<xsl:value-of select="@show"></xsl:value-of>
				</target>
			</xsl:for-each>
			<xsl:for-each select="./proto[@name='http']">
				<xsl:for-each select="field">
					<xsl:if test="@name!=''">
						<xsl:apply-templates select="."></xsl:apply-templates>
					</xsl:if>
					<xsl:if test="@name=''">
						<xsl:for-each select="./field">
							<xsl:apply-templates select="."></xsl:apply-templates>
						
						</xsl:for-each>
					</xsl:if>
				</xsl:for-each>
			</xsl:for-each>
			<field>
				<xsl:attribute name="name">data</xsl:attribute>
				<xsl:attribute name="show"><xsl:value-of select="./proto[@name='data-text-lines']/field[@name='']/@show"></xsl:value-of></xsl:attribute>
			</field>
		</packet>
		</xsl:for-each>
	</data>

	</xsl:template>
	
	<xsl:template match="field">
		<field><xsl:attribute name="name"><xsl:value-of select="@name"></xsl:value-of></xsl:attribute>
			<xsl:attribute name="show"><xsl:value-of select="@show"></xsl:value-of></xsl:attribute>
		</field>
	</xsl:template>
</xsl:stylesheet>
